package com.cn.customer.housekeeping.housekeepingc.ui.base;

import android.graphics.Bitmap;
import android.widget.ImageView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;


public class BaseImgView {


    public static ImageLoader imageLoader = ImageLoader.getInstance();

    public static void ImageLoaderLoadimg(ImageView imgView, String path, int defaultbg, int loadbg, int failbg,
                                          int width, int height, int RadiusPixels) {
        if (imgView == null || path == null) {
            return;
        }
        DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder();
        builder.showImageOnLoading(loadbg)
                .showImageForEmptyUri(defaultbg)
                .showImageOnFail(failbg)
                .cacheInMemory(true)
                .displayer(new FadeInBitmapDisplayer(1000))//是否图片加载好后渐入的动画时间
                .cacheOnDisk(true)
                .considerExifParams(true)
                .imageScaleType(ImageScaleType.EXACTLY)
                .bitmapConfig(Bitmap.Config.ARGB_8888);
        if (RadiusPixels > 0) {
            builder.displayer(new RoundedBitmapDisplayer(RadiusPixels));
        }
        DisplayImageOptions options = builder.build();

        if (path != null) {// 加载网络图片
            StringBuilder stringBuilder = new StringBuilder();
            if (width > 0 && height > 0) {
                stringBuilder.append(width).append("x").append(height);
                imageLoader.displayImage(path, imgView, options);
            } else {
            }
        }
    }


}
